package com.lightsaber.trade.as.dao.planning;

import org.springframework.stereotype.Component;
import org.springside.modules.orm.Page;

import com.lightsaber.trade.as.entity.planning.Level2Planning;
import com.lightsaber.trade.core.dao.BaseDao;

@Component
public class Level2PlanningDao extends BaseDao<Level2Planning, String> {
    //
    // @SuppressWarnings("unchecked")
    // public List<Integer> getAllPlanningExercise() {
    //
    // String hql =
    // "select distinct level2.planningExercise from Level2Planning level2 ";
    //
    // Query q = this.createQuery(hql, new HashMap<String, Object>());
    //
    // return q.list();
    // }

    public Level2Planning findByPlanningExercise(final Integer planningExercise) {
        eq("planningExercise", planningExercise);

        return unique();
    }

    public void findPage(final Level2Planning level2Planning, final Page<Level2Planning> page) {
        if (level2Planning.getPlanningExercise() != null) {

            int exercise = level2Planning.getPlanningExercise();
            if (exercise != 0) {
                eq("planningExercise", exercise);
            }
        }
        findPage(page);
    }

}
